<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {
	$this->_redirect(HOST_VFRIEND);
}
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$intVonTransfer	= (int)$objRequest->getParam('pcur_von',0);
$strToken		= $objRequest->getParam('token','');
$strSession		= isset($_SESSION['vTransfer' . $AppUI->id]) ? $_SESSION['vTransfer' . $AppUI->id] : '';
$intError		= 0;
$objVfriendUser	= new Vfriend_User();
$intVon			= $objVfriendUser->getAccount($AppUI->id, 1);
if($intVonTransfer == 0 || !isset($intVonTransfer)) {
	$intError	= 44;
}
elseif($intVon < $intVonTransfer && $intVonTransfer) {
	$intError	= 45;
}elseif($intVonTransfer && strlen($intVonTransfer) > 8) {
	$intError	= 46;
}
if($intError == 0) {	
	if($strToken != '' && $strSession != '' && $strToken == $strSession && Vfriend_Function::isValidLink($strRefer)) {
		unset($_SESSION['vTransfer' . $AppUI->id]);	
		$intError	= $objVfriendUser->updateUserTransferVon($AppUI->id, $intVonTransfer);
		if($intError == 0) {
			Vfriend_Function::setMsg($arrMessage[18]);
		} elseif($intError == 1) {
			$intError = 47; 
		} elseif($intError == 2) {
			$intError = 45;
		}
	} else {
		$intError	= 43;
	}
}
if($intError > 0) {
	Vfriend_Function::setError($arrError[$intError]);
}
Vfriend_Function::redirect($strRefer ? $strRefer : HOST_VFRIEND);
?>